/*
 * @Author: szx
 * @Date: 2022-03-26 12:30:16
 * @LastEditTime: 2022-03-26 12:42:00
 * @Description: 
 * @FilePath: \leetcode\600-699\682\682.js
 */
/**
 * @param {string[]} ops
 * @return {number}
 */
var calPoints = function (ops) {
    const st = [];
    for (let i of ops) {
        if (i === '+') {
            st.push(st[st.length - 1] + st[st.length - 2]);
        } else if (i === 'D') {
            st.push(st[st.length - 1] * 2);
        } else if (i === 'C') {
            st.pop();
        } else {
            st.push(Number(i));
        }
    }
    return st.reduce((a, b) => a + b, 0);
};
